package com.example.school.utils.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
@Slf4j
public class WebMvcConfiguration extends WebMvcConfigurationSupport {

   @Autowired
   private UserCheckToken userCheckToken;
   @Autowired
   private AdminCheckToken adminCheckToken;

    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(userCheckToken).addPathPatterns("/user/**").excludePathPatterns("/user/user/user_login");
        registry.addInterceptor(adminCheckToken).addPathPatterns("/admin/**").excludePathPatterns("/admin/user/admin_login");
    }

}
